# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_variant=-${KF5_VARIANT:-shared}
source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_kde_f5_init_package "${_variant}" "breeze"
pkgver=5.27.5
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
pkgdesc='Artwork, styles and assets for the Breeze visual style for the Plasma Desktop (mingw-w64)'
url='https://kde.org/plasma-desktop/'
license=('GPL' 'LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-kcmutils-qt5"
             "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-breeze-icons-qt5"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kcodecs-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kconfig-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kconfigwidgets-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kcoreaddons-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kguiaddons-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-ki18n-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kiconthemes-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kirigami2-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kwidgetsaddons-qt5${_namesuff}"
_kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-kwindowsystem-qt5${_namesuff}"
if [ "${_variant}" = "-static" ]; then
  _kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-qt5${_namesuff}"
else
  depends+=("${MINGW_PACKAGE_PREFIX}-qt5-base"
            "${MINGW_PACKAGE_PREFIX}-qt5-declarative")
fi
optdepends=("${MINGW_PACKAGE_PREFIX}-kcmutils-qt5: for breeze-settings")
groups=("${MINGW_PACKAGE_PREFIX}-plasma")
source=("https://download.kde.org/stable/plasma/${pkgver}/${_basename}-${pkgver}.tar.xz"{,.sig})
noextract=("${_basename}-${pkgver}.tar.xz")
sha256sums=('70d8a35bf8c0758f9c3e3873b657250b1e09c1c79f92b066d3385a1e44fec868'
            'SKIP')
validpgpkeys=('E0A3EB202F8E57528E13E72FD7574483BB57B18D') # Jonathan Esk-Riddell <jr@jriddell.org>

_extract_with_retry() {
  tar -xf "$1" || tar -xf "$1" || tar -xf "$1"
}

prepare() {
  _extract_with_retry "${srcdir}/${_basename}-${pkgver}.tar.xz"
  mkdir -p build-${MSYSTEM}${_variant}
}

build() {
  local -a extra_config
  cd build-${MSYSTEM}${_variant}
  if [ "${_variant}" = "-static" ]; then
    extra_config+=( -DBUILD_SHARED_LIBS=NO )
  fi

  _kde_f5_build_env
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "Ninja" \
    -DCMAKE_BUILD_TYPE=$(_kde_f5_CMAKE_BUILD_TYPE) \
    "${_kde_f5_KDE_INSTALL_DIRS[@]}" \
    -DBUILD_TESTING=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    -DCMAKE_DISABLE_FIND_PACKAGE_KF5FrameworkIntegration=ON \
    -DWITH_DECORATIONS=OFF \
    "${extra_config[@]}" \
    ../${_basename}-${pkgver}

  ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

package() {
  cd build-${MSYSTEM}${_variant}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install ./
}
